package com.jprocms.module.cms.dal.mysql.content;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.metadata.OrderItem;
import com.jpro.framework.datapermission.core.annotation.DataPermission;
import com.jpro.framework.datapermission.core.rule.dept.DeptDataPermissionRule;
import com.jpro.framework.mybatis.core.mapper.BaseMapperX;
import com.jprocms.module.cms.controller.admin.content.vo.ContentPageReqVO;
import com.jprocms.module.cms.controller.admin.content.vo.ContentSideReqVO;
import com.jprocms.module.cms.controller.admin.content.vo.ContentStatQueryReqVO;
import com.jprocms.module.cms.dal.dataobject.content.ContentDO;
import com.jprocms.module.cms.permission.ContentPermissionRule;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.io.Serializable;
import java.util.Collection;
import java.util.List;

/**
 * 内容 Mapper
 *
 * @author jprocms
 */
@Mapper
public interface ContentMapper extends BaseMapperX<ContentDO> {

    @Override
    ContentDO selectById(Serializable id);

    ContentDO selectByIdIgnoreDel(Serializable id);

    List<ContentDO> selectByContentIdsIgnoreDel(@Param("contentIds") Collection<Long> ids);

    List<ContentDO> selectByContentIds(@Param("contentIds") Collection<Long> ids, @Param("status") Integer status);

    @DataPermission(includeRules = {ContentPermissionRule.class, DeptDataPermissionRule.class})
    IPage<ContentDO> selectPage(@Param("params") ContentPageReqVO params,
                                @Param("orders") Collection<OrderItem> orders, IPage<ContentDO> page);

    List<ContentDO> selectList(@Param("params") ContentPageReqVO params, @Param("orders") Collection<OrderItem> orders);

    List<ContentDO> selectListStat(@Param("params") ContentStatQueryReqVO params);

    List<ContentDO> getListByMinId(@Param("minId") Long minId, @Param("siteId") Long siteId, @Param("status") Integer status);


    /**
     * 查询上一篇/下一篇内容
     *
     * @param params 内容上下篇查询
     * @return 上一篇/下一篇内容
     */
    List<ContentDO> selectPrev(@Param("params") ContentSideReqVO params);

    /**
     * 查询上一篇/下一篇内容
     *
     * @param params 内容上下篇查询
     * @return 上一篇/下一篇内容
     */
    List<ContentDO> selectNext(@Param("params") ContentSideReqVO params);

    List<ContentDO> listByOriginContentId(@Param("contentId") Long contentId);
}
